package shun.demo.future;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import shun.demo.R;

import java.util.Random;

/**
 * Created by chen on 3/8/14.
 */
public class FutureActivity extends Activity implements View.OnClickListener {

    private TextView mTextView;
    private String[] mFutures;
    private Random mRandom;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.future);
        mTextView = (TextView) findViewById(R.id.future_info);
        mFutures = getResources().getStringArray(R.array.future);
        mRandom = new Random();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.predict:
                mTextView.setText(predict());
                break;
        }
    }

    private String predict() {
        int n = mRandom.nextInt(mFutures.length);
        return mFutures[n];
    }

}